# (1) 按语文成绩排序（降序
title = ["序号","姓名","班级","语文","数学","英语","理综"]
marks = [["001","宋永欣",2,125,132,128,256],["002","朱力璇",2,132,123,135,232],["003","杜媛  ",1,132,141,132,263],
        ["004","马上宁",1,123,122,140,238],["005","栗怡  ",1,134,138,135,263],["006","贾患英",3,111,126,122,243],
        ["007","朱雅宁",4,128,135,141,278],["008","杨研  ",5,123,122,132,213],["009","赫宁  ",3,126,142,122,279],
        ["010","金芬  ",4,129,133,137,273],["011","秦斐  ",2,122,106,132,220]]

marks.sort(key=lambda x:x[3],reverse=True)
print("按语文成绩排序（降序）")
for x in title:
    print(x,end=" ")
print()
for num,name,classes,chinese,math,english,science in marks:
    print(num,name,classes,chinese,math,english,science)

# (2) 按数学成绩排序（降序）
title = ["序号","姓名","班级","语文","数学","英语","理综"]
marks = [["001","宋永欣",2,125,132,128,256],["002","朱力璇",2,132,123,135,232],["003","杜媛  ",1,132,141,132,263],
        ["004","马上宁",1,123,122,140,238],["005","栗怡  ",1,134,138,135,263],["006","贾患英",3,111,126,122,243],
        ["007","朱雅宁",4,128,135,141,278],["008","杨研  ",5,123,122,132,213],["009","赫宁  ",3,126,142,122,279],
        ["010","金芬  ",4,129,133,137,273],["011","秦斐  ",2,122,106,132,220]]

marks.sort(key=lambda x:x[4],reverse=True)
print("按数学成绩排序（降序）")
for x in title:
    print(x,end=" ")
print()
for num,name,classes,chinese,math,english,science in marks:
    print(num,name,classes,chinese,math,english,science)


# (3) 按总成绩排序（降序）
print("学生按照总成绩排序为：")
title.append('总成绩') # 新增一列
for x in title:
    print(x,end=" ")
print()
# 获取总成绩
for i in range(11):
    total = marks[i][3] + marks[i][4] + marks[i][5] + marks[i][6]
    marks[i].append(total)
marks.sort(key=lambda x:x[7],reverse=True)
for num,name,classes,chinese,math,english,science,total in marks:
    print(num,name,classes,chinese,math,english,science,total)